#include<bits/stdc++.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int a[n + 10][30];
	memset(a, 0, sizeof a);
	
	for(int i = n - 1; i >= 0; i -- ) {
		for(int j = 0; j < 26; j ++ ) {
			a[i][j] = a[i + 1][j];
		}
		a[i][s[i] - 'A'] ++ ;
	}
	int ret = 0;
	for(int i = 0; i < n - 2; i ++ ) {
		ret += a[i + 2][s[i] - 'A'];
	}
	cout << ret << endl;
	return 0;
}

